package com.kevin.thread;

import java.util.concurrent.*;

public class NewCachedThreadPoolTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
//        ExecutorService executorService = Executors.newCachedThreadPool();
//        Future<String> submit = executorService.submit(new MyThread1());
//        String s = submit.get();
//        System.out.println(s);
        ExecutorService service = Executors.newCachedThreadPool();
        Runnable runnable = ()->{
            while(true){
                try {
                    Thread.sleep(1000L);
                    System.out.println(Thread.currentThread().getName());
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        };
        service.submit(runnable);
        service.submit(runnable);
        service.shutdown();
    }
}

class MyThread1 implements Callable<String>{

    @Override
    public String call() throws Exception {
        return "fuck";
    }
}
